﻿using System.Configuration;
using TfsCloudDeploy.Deployment.Framework.Interfaces;

namespace TfsCloudDeploy.Deployment.Framework.Configuration
{
    public static class ConfigurationSettings
    {
        #region Logging

        private static readonly ILog _log = new Log(typeof(ConfigurationSettings));

        #endregion

        private const bool DEFAULT_IS_TRANSPORT_ONLY = false;

        public static string SiteRootPath
        {
            get
            {
                return ConfigurationManager.AppSettings["BuildShareRootLocalPath"];
            }
            private set { }
        }

        public static string ReleaseEnvironmentName
        {
            get
            {
                return ConfigurationManager.AppSettings["ReleaseEnvironmentName"];
            }
            private set { }
        }

        public static string[] DeploymentAdministrators
        {
            get
            {
                string deploymentAdministrators = ConfigurationManager.AppSettings["DeploymentAdministrators"];

                if (string.IsNullOrWhiteSpace(deploymentAdministrators))
                {
                    return new string[] { };
                }

                return deploymentAdministrators.Split(new char[] { ',' });
            }
            private set { }
        }

        public static bool IsTransportOnly
        {
            get
            {
                bool isTransportOnly = false;
                if (!bool.TryParse(ConfigurationManager.AppSettings["IsTransportOnly"], out isTransportOnly))
                {
                    isTransportOnly = DEFAULT_IS_TRANSPORT_ONLY;
                }

                return isTransportOnly;
            }
            private set { }
        }

        public static string TargetDeploymentTransportLocation
        {
            get
            {
                return ConfigurationManager.AppSettings["TargetDeploymentTransportLocation"];
            }
            private set { }
        }
    }
}
